/*
 * Copyright (c) 2024 Black Sesame Technologies
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef _DAL_FASTDDS_STATUS_CONVERTER_HPP_
#define _DAL_FASTDDS_STATUS_CONVERTER_HPP_

#include "dal/status.h"
#include "dal/ret_type.h"
#include <fastdds/dds/core/status/BaseStatus.hpp>
#include <fastdds/dds/core/status/SubscriptionMatchedStatus.hpp>
#include <fastdds/dds/core/status/PublicationMatchedStatus.hpp>
#include <fastdds/dds/core/status/DeadlineMissedStatus.hpp>
#include <fastdds/dds/core/status/IncompatibleQosStatus.hpp>
#include <fastdds/dds/core/status/LivelinessChangedStatus.hpp>
#include <fastdds/dds/core/status/LivelinessChangedStatus.hpp>
#include <fastdds/dds/core/status/SampleRejectedStatus.hpp>

using namespace eprosima::fastdds::dds;

class StatusConverter
{
protected:
    StatusConverter();
    static StatusConverter* singleton_;

public:
    StatusConverter(StatusConverter& other) = delete;
    void operator=(const StatusConverter&) = delete;
    static StatusConverter* GetInstance();

    dal_ret_t
    ConvertInconsistentTopicStatusFromFastddsToDal(const InconsistentTopicStatus* fstatus,
                                                   dal_inconsistent_topic_status_t* hstatus);

    dal_ret_t ConvertSampleLostStatusFromFastddsToDal(const SampleLostStatus* fstatus,
                                                      dal_sample_lost_status_t* hstatus);

    dal_ret_t ConvertSampleRejectedStatusFromFastddsToDal(const SampleRejectedStatus* fstatus,
                                                          dal_sample_rejected_status_t* hstatus);

    dal_ret_t ConvertLivelinessLostStatusFromFastddsToDal(const LivelinessLostStatus* fstatus,
                                                          dal_liveliness_lost_status_t* hstatus);

    dal_ret_t
    ConvertLivelinessChangedStatusFromFastddsToDal(const LivelinessChangedStatus* fstatus,
                                                   dal_liveliness_changed_status_t* hstatus);

    dal_ret_t ConvertOfferedDeadlineMissedStatusFromFastddsToDal(
        const OfferedDeadlineMissedStatus* fstatus, dal_offered_deadline_missed_status_t* hstatus);

    dal_ret_t ConvertRequestedDeadlineMissedStatusFromFastddsToDal(
        const RequestedDeadlineMissedStatus* fstatus,
        dal_requested_deadline_missed_status_t* hstatus);

    dal_ret_t ConvertOfferedIncompatibleQosStatusFromFastddsToDal(
        const OfferedIncompatibleQosStatus* fstatus,
        dal_offered_incompatible_qos_status_t* hstatus);

    dal_ret_t ConvertRequestedIncompatibleQosStatusFromFastddsToDal(
        const RequestedIncompatibleQosStatus* fstatus,
        dal_requested_incompatible_qos_status_t* hstatus);

    dal_ret_t
    ConvertPublicationMatchedStatusFromFastddsToDal(const PublicationMatchedStatus* fstatus,
                                                    dal_publication_matched_status_t* hstatus);

    dal_ret_t
    ConvertSubscriptionMatchedStatusFromFastddsToDal(const SubscriptionMatchedStatus* fstatus,
                                                     dal_subscription_matched_status_t* hstatus);
};

#endif  // _DAL_FASTDDS_STATUS_CONVERTER_HPP_
